package com.jhlishero.study.javase.clazz;

import java.lang.reflect.Method;

public class StaticClassAndStaticMethod {
    static {
        System.out.println("====static block====");
    }

    public static void main(String[] args) throws Exception {
        System.out.println("====static method====");

        Class<?> aClass = StaticClassAndStaticMethod.class.getClassLoader().loadClass("com.jhlishero.study.javase.clazz.ClassDemo");

        System.out.println("class name=" + aClass.getName());


        ClassDemo.init();
        //Object o = aClass.getConstructor().newInstance();

        Class<?> paramTypes[] = new Class[1];
        paramTypes[0] = Class.forName("com.jhlishero.study.javase.clazz.User");
        Method method = aClass.getMethod("add", paramTypes);

        Object paramValues[] = new Object[1];
        paramValues[0] = new User();
        method.invoke(aClass.newInstance(), paramValues);

    }
}
